<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + " ://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<jsp:include page="root_public.jsp"/>
<title>个人信息</title>
</head>

<body>
<div class="x-body">
    <form class="layui-form" action="<%=path%>/user/updatePassword">
        <div class="layui-form-item">
            <label for="password" class="layui-form-label">
                <span class="x-red">*</span>新密码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="password" name="password" required=""
                       autocomplete="off" class="layui-input" lay-verify="password">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="password2" class="layui-form-label">
                <span class="x-red">*</span>确认密码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="password2" name="password2" required=""
                       autocomplete="off" class="layui-input" lay-verify="password2">
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" style="display: block;margin: 0 auto;" lay-filter="updatePasswords" lay-submit="">
                修改
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        form.verify({
            password2: function (value) {
                if (value != $('#password').val()) {
                    return "两次密码输入不一致哦";
                }
            }
            , password: [
                /^[\S]{6,16}$/
                , '密码必须6到16位，且不能出现空格'
            ]
        });

        //监听提交
        form.on('submit(updatePasswords)', function (data) {
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //关闭当前frame
            parent.layer.close(index);
        });
    });
</script>
</body>
</html>